<?php

namespace App\Model;


class GameTaskGrowComplete extends Model
{
    protected $table = 'game_task_grow_complete';
    protected $fillable = ['uid', 'game_id', 'grow_task_id', 'complete_num', 'is_complete', 'is_get', 'create_at', 'update_at'];
    public $timestamps = false;

    public static function insertRecord($data)
    {
        try {
            self::query()->insert($data);
            return ['code' => 0, 'msg' => '插入成功！'];
        } catch (\Exception $e) {
            return ['code' => 1, 'msg' => $e->getMessage()];
        }
    }

    public static function updateRecord($id, $datas)
    {
        try {
            self::query()->where('id', $id)->update($datas);
            return ['code' => 0, 'msg' => '更新成功！'];
        } catch (\Exception $e) {
            return ['code' => 1, 'msg' => $e->getMessage()];
        }
    }

    public static function checkRecord($where)
    {
        try {
            $data = self::query()->where($where)->first();
            if (empty($data)) {
                return ['code' => 2, 'msg' => '未找到记录！'];
            }
            return ['code' => 0, 'msg' => '获取成功！', 'data' => $data->toArray()];
        } catch (\Exception $e) {
            return ['code' => 1, 'msg' => $e->getMessage()];
        }
    }
}